home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 3.2
/
Ham Radio Version 3.2 (Chestnut CD-ROMs)(1993).ISO
/
packet
/
findx
/
findx.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-11-22
|
3KB
|
132 lines
program parse_domain(input, output);
uses Crt, argx;
type
text_line = string[81];
var
domain: TEXT;
in_line, last_line: text_line;
search_string: string[40];
response: char;
line_no, args, hits : integer;
first_time: boolean;
function upper(instring: string): string;
var
i0 : integer;
begin
upper[0] := chr(length(instring));
for i0 := 1 to length(instring) do
if (ord(instring[i0]) > 96)
and (ord(instring[i0]) < 122) then
upper[i0] := chr(ord(instring[i0]) - 32)
else
upper[i0] := instring[i0]
end;
procedure print_it(out_line: string);
var
i0: integer;
begin
if line_no = 20 then begin
line_no := 0;
writeln; writeln('Press ENTER to continue...');
readln;
ClrScr;
end;
for i0 := 1 to length(out_line) do
if ord(out_line[i0]) < 32 then
out_line[i0] := chr(32);
writeln(out_line);
line_no := line_no + 1
end;
function hit: boolean;
var
temp: boolean;
check_str: string[40];
last_search, i0 : integer;
begin
temp := false;
last_search := length(in_line) - length(search_string) + 1;
if last_search > 0 then begin
i0 := 1;
while (not temp) and (i0 <= last_search) do begin
check_str := copy(in_line,i0,length(search_string));
if upper(check_str) = upper(search_string) then
temp := true
else
i0 := i0 + 1
end
end;
hit := temp
end;
begin
assign(domain,'\domain.txt');
response := 'y';
first_time := true;
while response in ['Y','y'] do begin
ClrScr;
line_no := 0;
hits := 0;
args := arg_count;
if (args > 0) and
first_time then begin
search_string := arg_string(1);
first_time := false;
writeln('Searching for "', search_string, '"...')
end
else begin
write('Enter search string: ');
readln(search_string)
end;
reset(domain);
readln(domain, in_line);
last_line := '';
while not eof(domain) do
if hit then begin
hits := hits + 1;
if in_line[1] <> '#' then
print_it(last_line);
repeat
print_it(in_line);
last_line := in_line;
readln(domain,in_line)
until in_line[1] = '#'
end
else begin
last_line := in_line;
readln(domain, in_line);
end;
writeln;
if hits < 1 then
writeln('No matching records!')
else
writeln(hits,' matches listed.');
writeln('Press ENTER to continue...');
readln;
if args > 0 then
response := 'n'
else begin
write('Another query? [y|n]: ');
readln(response)
end
end;
close(domain)
end.